<?php
namespace app\index\controller;
use think\Config;
use think\Db;

class Message extends Common
{
	//消息列表
    public function index()
    {
		$page=request()->param('page');
		if(!$page | $page<1)
		{
			$page = 1;
		}
		
		
		
		$url=Config::get("block_url");
		$url = $url . "v1/index/message/list";
		$arr['page']=$page;
		$arr['limit']=20;
		
		$info = $this->curl_request($url,$arr);
		
		
		
		$cinfo = json_decode($info,true);
		$data = $cinfo['data'];
		foreach($data AS &$c)
		{
			$c['timestamp'] = date("Y-m-d H:i:s",$c['timestamp']);
			$c['Value'] = $this->chk_num($c['Value']);
			//print_r($c);
		}
		unset($c);
		
		
		//exit;
		//var_dump($data);exit;
		
		$page_arr=array();
		$page_arr['this']=$page;
		$page_arr['next']=$page+1;
		$page_arr['pre']=$page-1;
		//$page_arr['next_last']=10;
		$page_arr['next_last']=$cinfo['echo'];
		
		
		
		$this->assign("data",$data);
		$this->assign("page",$page_arr);
		
		return $this->fetch();
    }
	
}
